// TODO
// depend
.size(@width; @height) {
    width: @width;
    height: @height;
}

.square(@size) {
    .size(@size; @size);
}
@table-prefix-cls: ~"@{css-prefix}table";

@spin-prefix-cls: ~"@{css-prefix}spin";
@spin-dot-size-mini: 10px;
@spin-dot-size-small: 14px;
@spin-dot-size: 20px;
@spin-dot-size-large: 32px;

@spin-default-size-small: 20px;
@spin-default-size: 32px;
@spin-default-size-large: 44px;

.@{spin-prefix-cls} {
    color: @color-brand-primary;
    vertical-align: middle;
    text-align: center;
    .square(@spin-dot-size);
    &-type-dot {
        position: relative;
        display: block;
        border-radius: 50%;
        background-color: @color-brand-primary;
        .square(@spin-dot-size);
        animation: ani-spin-bounce 1s 0s ease-in-out infinite;
    }
    &-white {
        background-color: @primary-color
    }
    &-large {
        .square(@spin-dot-size-large);
    }
    &-small {
        .square(@spin-dot-size-small);
    }
    &-mini {
        .square(@spin-dot-size-mini);
    }

    &-large &-type-dot {
        .square(@spin-dot-size-large);
    }

    &-small &-type-dot {
        .square(@spin-dot-size-small);
    }

    &-mini &-type-dot {
        .square(@spin-dot-size-mini);
    }

    &-type-circular {
        animation: rotate 2s linear infinite;
        transform-origin: center center;
        .square(@spin-dot-size);
    }

    &-main-path {
        stroke-dasharray: 1,200;
        stroke-dashoffset: 0;
        animation: dash 1.5s ease-in-out infinite,color 6s ease-in-out infinite;
        stroke-linecap: round;
    }
    
    &-large &-type-circular {
        .square(@spin-dot-size-large);
    }

    &-small &-type-circular {
        .square(@spin-dot-size-small);
    }

    &-mini &-type-circular {
        .square(@spin-dot-size-mini);
    }

    &-type-circular &-gray {
        stroke: gray;
    }

    &-type-circular &-blue {
        stroke: @color-brand-primary;
    }

    &-type-circular &-white {
        stroke: white;
        background-color: @color-brand-primary;
    }

    &-type-default {
        position: relative;
        display: block;
        background: url();
        background-size: cover;
        .square(@spin-default-size);
    }

    &-large &-type-default {
        .square(@spin-default-size-large);
    }

    &-small &-type-default {
        .square(@spin-default-size-small);
    }

    &-fix {
        position: absolute;
        top: 0;
        left: 0;
        z-index: @zindex-spin;
        .square(100%);
        background-color: rgba(255,255,255,.9);
    }
    &-fullscreen {
        z-index: @zindex-spin-fullscreen;
        &-wrapper {
            position: fixed;
            top: 0;
            right: 0;
            bottom: 0;
            left: 0;
        }
    }

    &-fix &-main {
        position: absolute;
        top: 50%;
        left: 50%;
        -ms-transform: translate(-50%, -50%);
        transform: translate(-50%, -50%);
    }

    &-fix &-circular {
        display: inline-block;
    }

    &-fix &-dot {
        display: inline-block;
    }
    
    &-fix &-default {
        display: inline-block;
    }

    &-text,
    &-show-text &-circular {
        display: none;
    }
    
    &-text,
    &-show-text &-dot {
        display: none;
    }
    
    &-text,
    &-show-text &-default {
        display: none;
    }

    &-show-text &-text {
        display: block;
    }
}

// use in Table loading, Table right border is not included in .haloe-table-wrapper, so fix it
.@{table-prefix-cls}-wrapper{
    > .@{spin-prefix-cls}-fix{
        border: none;
    }
}
.@{table-prefix-cls}-wrapper-with-border{
    > .@{spin-prefix-cls}-fix{
        border: 1px solid @color-brand-primary;
        border-top: 0;
        border-left: 0;
    }
}

@keyframes ani-spin-bounce {
    0% {
        transform: scale(0);
    }

    100% {
        transform: scale(1);
        opacity: 0;
    }
}

@keyframes rotate {
    100% { transform: rotate(1turn); }
  }
  
  @keyframes dash {
    0% {
      stroke-dasharray: 1,200;
      stroke-dashoffset: 0;
    }
    50% {
        stroke-dasharray: 89,200;
        stroke-dashoffset: -35;
    }
    100% {
        stroke-dasharray: 89,200;
        stroke-dashoffset: -124;
    }
  }
